
#include<stdio.h>
#include <unistd.h>
#include<string.h>
#define SIZE 101
#define STYLE '#'

void FlushProcess(double total,double current)
{
    char buffer[SIZE];
    const char* lable="|/-\\";
    int len=strlen(lable);
    int num=(current*100)/total;
    memset(buffer,0,sizeof(buffer));
    
    for(int i=0;i<num;i++)
    {
        buffer[i]=STYLE;
    }
    static int cnt=0;
    double rate=current/total;
    printf("[%-100s][%.1f%%][%c]\r",buffer,rate*100,lable[cnt]);
    cnt++;
    cnt%=len;
    fflush(stdout);
}

void process()
{
    char buffer[SIZE];
    memset(buffer,0,sizeof(buffer));
    const char* lable="|/-\\";
    for(int i=0;i<=100;i++)
    {
        printf("[%-100s][%d%%][%c]\r",buffer,i,lable[i%4]);
        fflush(stdout);
        buffer[i]=STYLE;
        usleep(50000);
    }
    printf("\n");
}
